new Handle:g_Goto = INVALID_HANDLE
new bool:AGoto[MAXPLAYERS+1] = true

public Action:Do_Goto(client,args)
{
	if(GetConVarInt(g_Goto) != 1){
		PrintToChat(client, "\x01\x04[SYN] Goto Disabled!")
		return Plugin_Handled
	}

    //Error:
	if(args < 1)
	{

		//Print:
		PrintToConsole(client, "Usage: sm_goto <name>")
		PrintToChat(client, "Usage:\x04 sm_goto <name>")

		//Return:
		return Plugin_Handled
	}
	
	//Declare:
	decl Player
	decl String:PlayerName[32], String:Name[32]
	new Float:PlayerOrigin[3]
	
	//Initialize:
	Player = -1
	GetCmdArg(1, PlayerName, sizeof(PlayerName))
	
	//Find:
	for(new i = 1; i <= MaxClients; i++)
	{

		//Connected:
		if(!IsClientConnected(i)) 
			continue

		//Initialize:
		GetClientName(i, Name, sizeof(Name))

		//Save:
		if(StrContains(Name, PlayerName, false) != -1) 
			Player = i
	}
	
	//Invalid Name:
	if(Player == -1)
	{

		//Print:
		PrintToConsole(client, "Could not find client \x04%s", PlayerName)

		//Return:
		return Plugin_Handled
	}
	
	GetClientName(Player, Name, sizeof(Name));
	
	if(!AGoto[Player] || IsFakeClient(Player)){
		PrintToChat(client, "\x01\x04[SYN] The Player %s disabled goto", Name)
		return Plugin_Handled
	}
	else
	{
		PrintToChat(Player, "\x01\x04[SYN] To disable/enable goto type !nogoto", Name)
	}

	if (PlayerSpawned(Player) && PlayerSpawned(client))
	{
		GetClientAbsOrigin(Player, PlayerOrigin)
		//Teleport
		TeleportEntity(client, PlayerOrigin, NULL_VECTOR, NULL_VECTOR)
		
		PrintToChat(client, "\x01\x04[SYN] Teleported to %s", Name)
	}

	return Plugin_Handled
}

//public MenuHandler1(Handle:menu, MenuAction:action, param1, param2)
//{
//	/* If an option was selected, tell the client about the item. */
//	if (action == MenuAction_Select)
//	{
//		new player
//		decl String:info[32]
//		new bool:found = GetMenuItem(menu, param2, info, sizeof(info));
//
//		if (Debug)
//			PrintToConsole(param1, "You selected item: %d (found? %d info: %s)", param2, found, info);
//
//		if (!found)
//			return
//		
//		player = GetClientOfUserId(BClient[param1])
//		
//		if(param2 == 0)
//		{
//			if (PlayerSpawned(param1))
//			{
//				GetClientAbsOrigin(param1, PlayerOrigin)
//				//Teleport
//				TeleportEntity(player, PlayerOrigin, NULL_VECTOR, NULL_VECTOR)
//				
//				PrintToChat(player, "Teleported")
//			}
//			else
//			{
//				PrintToChat(player,"\x01\x04[SM] %T", "Notice_Dead", LANG_SERVER)
//			}
//		}
//		
//		if(param2 == 1)
//		{
//			PrintToChat(player, "Disallowed")
//		}
//	}
//	/* If the menu was cancelled, print a message to the server about it. */
//	else if (action == MenuAction_Cancel)
//	{
//		//PrintToServer("Client %d's menu was cancelled.  Reason: %d", param1, param2);
//	}
//	/* If the menu has ended, destroy it */
//	else if (action == MenuAction_End)
//	{
//		CloseHandle(menu);
//	}
//}
// 
//public Action:Menu_Goto(Handle:timer,any:client)
//{
//	new player
//	new Handle:menu = CreateMenu(MenuHandler1)
//	decl String:Name[32]
//	player = GetClientOfUserId(BClient[client])
//	GetClientName(player, Name, sizeof(Name))
//	SetMenuTitle(menu, "%s wants to go to your position! Allow?", Name)
//	AddMenuItem(menu, "yes", "Yes")
//	AddMenuItem(menu, "no", "No")
//	SetMenuExitButton(menu, false)
//	DisplayMenu(menu, client, 30)
// 
//	return Plugin_Handled
//}